package com.niji.littly_donkey_android.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.adapter.BillWithdrawalAdapter;
import com.niji.littly_donkey_android.bean.BillDetails;
import com.niji.littly_donkey_android.util.StatusBarUtil;
import com.niji.littly_donkey_android.util.TimeUtil;

import java.util.ArrayList;
import java.util.Date;
import java.util.Random;

public class BillWithdrawalActivity extends AppCompatActivity {

    /**
     * 返回
     */
    private Button bill_withdrawal_return;

    /**
     * 列表
     */
    private ListView bill_withdrawal_list;


    /**
     * 列表
     */
    private ArrayList<BillDetails> billDetails;

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bill_withdrawal_activity);
        init();
        billWithdrawalReturn();
        changeStatusBarTextImgColor(true);
    }
    /**
     * 界面设置状态栏字体颜色
     */
    public void changeStatusBarTextImgColor(boolean isBlack) {
        if (isBlack) {
            //设置状态栏黑色字体
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        } else {
            //恢复状态栏白色字体
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }
    @Override
    protected void onStart() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            //不加这个clearFlags好像就没效果
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            //设置导航栏透明(就是虚拟键那一栏)
             
            //设置状态栏(或者叫通知栏)透明
             
            window.setStatusBarColor(Color.TRANSPARENT);
        }
        super.onStart();
    }

    private void init() {

        bill_withdrawal_list = findViewById(R.id.bill_withdrawal_list);
        billDetails = new ArrayList<>();
        for (int i = 0; i < 50; i++) {
            Random random = new Random();
            BillDetails billDetail = new BillDetails();
            billDetail.setTime(TimeUtil.timeCompareYMDHMinSFigure(new Date().getTime()));
            billDetail.setMoney("-" + random.nextInt(100) + "元");
            billDetail.setName("提现到银行卡" + (i + 1));
            billDetails.add(billDetail);
        }
        bill_withdrawal_list.setAdapter(new BillWithdrawalAdapter(this,billDetails));

    }


    private void billWithdrawalReturn() {
        bill_withdrawal_return = findViewById(R.id.bill_withdrawal_return);
        bill_withdrawal_return = findViewById(R.id.bill_withdrawal_return);
        bill_withdrawal_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                overridePendingTransition(R.anim.xpage_slide_in_left,R.anim.xpage_slide_out_right);
                finish();
            }
        });
    }

}
